﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Data;
using saveimagetodatabase;
using System.Collections.ObjectModel;

namespace WcfServiceLibrary2
{
    [DataContract]
  public  class LopHoc
    {
        [DataMember]
        public int Malop{get;set;}
        [DataMember]
        public string Tenlop{get;set;}
        public LopHoc()
        {

        }
        public LopHoc(DataRow row)
        {
            this.Malop = row.IsNull("id") ? 0 : int.Parse(row["id"].ToString());
            this.Tenlop = row.IsNull("hoten") ? string.Empty : row["hoten"].ToString();
        }
        public static ObservableCollection<LopHoc>GetAllLopHoc()
        {
          try
          {
              ObservableCollection<LopHoc> list = new ObservableCollection<LopHoc>();
              SqlQuery sql = new SqlQuery();
              DataTable data = sql.SelectAll("selectsinhvien");
              foreach (DataRow row in data.Rows)
              {
                  list.Add(new LopHoc(row));
              }
              return list;
          }
          catch (System.Exception ex)
          {
              throw new Exception(ex.Message);
          }
        }
       
    }
}
